package com.hfi.ood.litejunit.v3.biz.calculator;

import com.hfi.ood.litejunit.v3.framework.annotation.*;
import com.hfi.ood.litejunit.v3.framework.runner.JUnitCore;

import static com.hfi.ood.litejunit.v3.framework.Assert.assertEquals;

/**
 * @author ChangLiang
 * @date 2020/5/28
 */
public class CalculatorTest {

    Calculator calculator = null;

    @Before
    public void prepare() {
        calculator = new Calculator();
    }

    @After
    public void clean() {
        calculator = null;
    }

    @Test
    public void testAdd() {
        calculator.add(10);
        assertEquals(10,calculator.getResult());
    }

    @Test
    public void testSubtract(){
        calculator.add(10);
        calculator.subtract(5);
        assertEquals(4,calculator.getResult());
    }

    @BeforeClass
    public static void prepareGlobalResource() {
        System.err.println("prepare Calculator global resource");
    }

    @AfterClass
    public static void cleanGlobalResource() {
        System.err.println("clean Calculator global resource");
    }

    public static void main(String[] args) {
//        JUnitCore.runClass(CalculatorTest.class);
        JUnitCore.main(args);
    }
}
